package com.example.module_hzd_host

import android.os.Bundle
import android.view.View
import com.example.module_hp_zao_yin_media.fragment.HpZaoYinPhotoFragment
import com.example.module_hp_zao_yin_media.fragment.HpZaoYinVideoFragment
import com.example.module_hzd_host.databinding.FragmentFenbeiSecondpageBinding
import com.fwlst.lib_base.fragment.BaseMvvmFragment
import com.fwlst.lib_base.model.BaseViewModel
import com.fwlst.lib_base.utils.AdUtils
import com.fwlst.lib_base.utils.JtXXPermissions
import com.hjq.permissions.Permission

class FenBeiSecondPageFragment :
    BaseMvvmFragment<FragmentFenbeiSecondpageBinding, BaseViewModel>() {
    override fun initLayout(): Int {
        return R.layout.fragment_fenbei_secondpage
    }

    override fun initBR(): Int {
        return 0
    }

    override fun initView(view: View, savedInstanceState: Bundle?) {

        childFragmentManager.beginTransaction().replace(R.id.flContainer, HpZaoYinPhotoFragment())
            .commit()
        binding.ivTab1.setOnClickListener {
            binding.ivTab1.setImageResource(R.mipmap.a_pz_2)
            binding.ivTab2.setImageResource(R.mipmap.a_pz_1)
            binding.flContainer.removeAllViews()
            childFragmentManager.beginTransaction()
                .replace(R.id.flContainer, HpZaoYinPhotoFragment()).commit()
        }
        binding.ivTab2.setOnClickListener {
            AdUtils.checkFunction(requireContext()) {
                val list = listOf(Permission.RECORD_AUDIO, Permission.CAMERA)
                JtXXPermissions.requestPermission(requireContext(),"",list){
                    binding.ivTab1.setImageResource(R.mipmap.a_pz_3)
                    binding.ivTab2.setImageResource(R.mipmap.a_pz_4)
                    binding.flContainer.removeAllViews()
                    childFragmentManager.beginTransaction().replace(
                        R.id.flContainer,
                        HpZaoYinVideoFragment()
                    ).commit()
                }
            }
        }
    }
}